import IScript from "../IScript";
import root from "../../types/msg"
import {move } from "../../msg/msg"
import {friend } from "../../msg/msg"
import MsgSend from "../../msg/MsgSend";
import ObjContainer from "../../ObjContainer";
import Player from "../../Player";

export  class S2C_SyncPositionScript implements IScript {

    private static  _instance = new S2C_SyncPositionScript()
    public static get instance(){
        return S2C_SyncPositionScript._instance;
    }
    private constructor(){}

    excute(obj: any) {
        this.handle(obj )
    }

    handle(msg: root.move.S2C_SyncPosition) {
        console.log("收到服务器同步坐标消息：",msg);
        //同步坐标
        let player = ObjContainer.getPlayer(msg.str)
        if(player ){
            player.x = msg.x
            player.y = msg.y
        }
    }
}

export default S2C_SyncPositionScript.instance
